package com.mmall.order.controller;

import com.mmall.common.spring.security.LoginRequired;
import com.mmall.common.spring.security.UserSecurityContextHolder;
import com.mmall.order.api.dto.OrderCreateDTO;
import com.mmall.order.api.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;

/**
 * @author hejianglong
 * @date 2019/10/23
 */
@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private OrderService orderService;

    @PostMapping("/create")
    @LoginRequired
    public void createOrder(@Valid OrderCreateDTO orderCreateDTO) {
        Long userId = UserSecurityContextHolder.getContext().getUserId();
        orderService.createOrder(userId, orderCreateDTO);
    }
}
